import { ref } from 'vue'
// 导入模型解析构造函数
import { Application } from '@splinetool/runtime'

function useInit3d() {
  // 初始化3d模型
  const ref3d = ref(null)
  const showLoading = ref(false)
  const init3dModel = () => {
    showLoading.value = true
    // 实例化解析器实例
    let spline = new Application(ref3d.value)
    // 拉取模型
    spline.load('https://fe-hmzs.itheima.net/scene.splinecode').then(() => {
      console.log('3D模型加载并渲染完毕')
      showLoading.value = false
    })
  }
  return {
    ref3d,
    init3dModel,
    showLoading
  }
}

export { useInit3d }